package orgs.example.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import orgs.example.pojo.Result;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e){
        e.printStackTrace();
        if(e.getMessage() != null){
            return Result.error(e.getMessage());
        }
        else{
            return Result.error("操作失败");
        }
    }
}
